<?
/***************************************************************************
Descri��o: Esta classe retorna o codigo da disciplina a ser insersida.
Autor: M�rcio R. Silva
***************************************************************************/
class xCodResolucao
{
	public function loadCodigo ($codSetor)
	{
		try
		{
		
                    $db = Database::singleton ();

			$sth = $db->prepare ("select max(res.protocolo)+1 as protocolo from cpcx.resolucao res
 join cpcx.ano ano ON ano.anoid=res.anoid
 where ano.status='1' and res.setorid=".$codSetor);

			$sth->execute ();
			
			$obj = $sth->fetch (PDO::FETCH_OBJ);
			
			if( isset($obj->protocolo))
				return $obj->protocolo;
			else
				return '1';
	
		}
		catch (PDOException $e)
		{
			toLog ($e->getMessage ());
		}
		catch (Exception $e)
		{
			toLog ($e->getMessage ());
		}		
	}

       
        private function digito($acaocodigo)
	{
          
           $programa=substr($acaocodigo,0,2);
           $acao=(int)substr($acaocodigo,2,2) + 1;
           if(strlen($acao)<2){
               $acao="0".$acao;
           }
           
           return $programa.$acao;
        }
	
	public function showMessages ()
	{
		$message = Message::singleton ();

		if (!is_object ($message) || !$message->has ())
			return FALSE;

		$str = '';
		while ($msg = $message->get ())
			$str .= $msg;

		$msgs = &XOAD_HTML::getElementById ('labelMessage');

		$msgs->innerHTML = '<div id="idMessage">'. utf8_encode ($str) .'</div>';

		$message->clear ();

		return TRUE;
	}

	public function delay ()
	{
		sleep (1);
	}

	public function xoadGetMeta()
	{
		$methods = get_class_methods ($this);
		
		XOAD_Client::mapMethods ($this, $methods);

		XOAD_Client::publicMethods ($this, $methods);
		
		XOAD_Client::privateMethods ($this, array ());
	}
}
?>